package band.wukong.practice.java.core.topic.generic;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Future;

/**
 * @author wukong(wukonggg@139.com)
 */
public class GenericComplexSample {

    private <T> List<T> cashFutures1(List<Future<T>> futures) {

        List<T> values = new ArrayList<T>();
        for (Future<T> future : futures) {
            try {
                values.add(future.get());
            } catch (Exception e) {
                throw new IllegalStateException(e);
            }
        }
        return values;
    }

    private <T> List cashFutures2(List<Future<T>> futures) {

        List<T> values = new ArrayList<T>();
        for (Future<T> future : futures) {
            try {
                values.add(future.get());
            } catch (Exception e) {
                throw new IllegalStateException(e);
            }
        }
        return values;
    }
}
